<%@page import="com.sun.xml.internal.bind.v2.schemagen.xmlschema.Import"%>
<%@page import="java.util.ArrayList"%>
<%@page import="Model.*"%>
<%@page import="POJO.*"%>
<%
	//doi table theo view
		ArrayList<CategoryPOJO> listcategory =  CategoryModel.SelectCategoryByALL();
	%>
	<% String id = (String)request.getAttribute("id"); 
	ProductPOJO Product = null;	

	if(id != null)
	{
		Product = ProductModel.SelectProductByID(id);
	}
%>
<!-- start content-outer -->
<div id="content-outer">
<!-- start content -->
<div id="content">


<div id="page-heading"><h1><% if(Product!=null){out.print("Update Product");}else{out.print("Add Product");} %></h1></div>


<table border="0" width="100%" cellpadding="0" cellspacing="0" id="content-table">
<tr>
	<th rowspan="3" class="sized"><img src="images/shared/side_shadowleft.jpg" width="20" height="300" alt="" /></th>
	<th class="topleft"></th>
	<td id="tbl-border-top">&nbsp;</td>
	<th class="topright"></th>
	<th rowspan="3" class="sized"><img src="images/shared/side_shadowright.jpg" width="20" height="300" alt="" /></th>
</tr>
<tr>
	<td id="tbl-border-left"></td>
	<td>
	<!--  start content-table-inner -->
	<div id="content-table-inner">
	
	<table border="0" width="100%" cellpadding="0" cellspacing="0">
	<tr valign="top">
	<td>

	
		<!-- start id-form -->
<form action="product" method="post">
		<table border="0" cellpadding="0" cellspacing="0"  id="id-form">
		<tr>
			<th valign="top">Product name:</th>
			<td><input name="txtname" type="text" class="inp-form" value="<%if(Product != null) out.print(Product.GetName()); %>" /></td>
			<td></td>
		</tr>
		
		<tr>
		<th valign="top">Category:</th>
		<td>	
		<select name="txtcategory" class="styledselect_form_1">
			<%
				CategoryPOJO ca=null;
				for(int i=0;i<listcategory.size();i++)
				{
					ca=listcategory.get(i);
			%>
			<option value="<%= ca.GetID() %>"><%= ca.GetName() %></option>
			
			<%} %>
		</select>
		</td>
		<td></td>
		</tr>
		<tr>
			<th valign="top">Price:</th>
			<td><input name="txtprice" type="text" class="inp-form" value="<%if(Product != null) out.print(Product.GetPrice()); %>" /></td>
			<td></td>
		</tr>
		<tr>
			<th valign="top" >Number:</th>
			<td><input name="txtnumber" type="text" class="inp-form" value="<%if(Product != null) out.print(Product.GetNumber()); %>"/></td>
			<td></td>
		</tr>
		<tr>
		<th valign="top" >Description:</th>
		<td><textarea name="txtdes" rows="" cols="" class="form-textarea" ><%if(Product != null) out.print(Product.Getinformation());%></textarea></td>
		<td></td>
		</tr>
		
	<tr>
		<th>&nbsp;</th>
		<td valign="top">
			<input type="hidden" value="<%if(Product!=null) {out.print("Edit");}else{out.print("Add");}%>" name="do"/>
			<input type="hidden" value="<%if(Product!=null) out.print(Product.GetID()); %>" name="idedit"/>
			<input type="submit" value="" class="form-submit" />
			<input type="reset" value="" class="form-reset"  />
		</td>
		<td></td>
	</tr>
	</table>
	<!-- end id-form  -->
</form>
	</td>
	
</tr>
<tr>
<td><img src="images/shared/blank.gif" width="695" height="1" alt="blank" /></td>
<td></td>
</tr>
</table>
 
<div class="clear"></div>
 

</div>
<!--  end content-table-inner  -->
</td>
<td id="tbl-border-right"></td>
</tr>
<tr>
	<th class="sized bottomleft"></th>
	<td id="tbl-border-bottom">&nbsp;</td>
	<th class="sized bottomright"></th>
</tr>
</table>




<div class="clear">&nbsp;</div>

</div>
<!--  end content -->
<div class="clear">&nbsp;</div>
</div>
<!--  end content-outer -->